#!/usr/local/bin/python

# Helper code borrowed from http://mkaz.com/math/primes.html

import os, string

primes = [2,3]
start = 5
max = 50000

# range of numbers searching for primes
for num in range(start, max):
    #intialize not-a-prime as false
    nap = 0

    # cycle through list of known primes
    for prime in primes:    
        # check if a previous prime divides evenly
        # into the current number -- if so the number
        # we are checking (num) is not a prime
        if (num % prime) == 0:
            nap = 1
            break
        # if prime squared is bigger than the number 
        # than we don't need to check any more
        if prime*prime > num:
           break

    # did we determine it's not a prime
    # if not, then we found a prime
    if nap != 1:
        # add prime to list of known primes
        primes.append(num)

print primes
print "Total number of primes in list: ", len(primes)
